<include file="Common:minheader" />
<!-- /. NAV SIDE  -->
<div class="layui-fluid">
	<div class="layui-row">
		<b>原卡信息</b><hr>
		<div class="layui-col-xs12 layui-col-sm12 layui-col-md12 hg" style="height:40px; line-height:40px">
			卡项：{$info.card_name}
		</div>
		<div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hg">
			剩余次数：{$info.nums}
		</div>
		<div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hg">
			开始时间：{$info.begin_time}
		</div>
		<div class="layui-col-xs4 layui-col-sm4 layui-col-md4 hg">
			结束时间会员：{$info.end_time}
		</div>
	</div>
</div>
<hr />
<form class="layui-form" action="">
    <input type="hidden" name="id" value="{$info.id}">
	<div class="layui-form-item">
		<label class="layui-form-label">选择产品</label>
		<div class="layui-input-block">
			<select name="goods_id" lay-verify="required" lay-search>
				<option value="">请选择</option>
				<notempty name="goods_list">
					<volist name="goods_list" id="vo">
						<option value="{$vo.id}">{$vo.goods_title}-（{$vo.total_nums}）</option>

					</volist>
				</notempty>
			</select>
		</div>
	</div>
	<div class="layui-form-item" id="cardNums">
		<label class="layui-form-label">次数</label>
		<div class="layui-input-block">
		  <input value="" type="text" name="nums" required  lay-verify="required" placeholder="请输入次数" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">开始时间</label>
		<div class="layui-input-block">
			<input type="text" name="begin_time" placeholder="请选择开始时间" autocomplete="off" class="layui-input" id="addtime_fromdate">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">结束时间</label>
		<div class="layui-input-block">
			<input type="text" name="end_time" placeholder="请选择结束时间" autocomplete="off" class="layui-input" id="addtime_fromdate">
		</div>
	</div>
	<div class="layui-form-item" id="cardNums">
		<label class="layui-form-label">费用</label>
		<div class="layui-input-block">
		  <input value="" type="text" name="expense" required  lay-verify="required" placeholder="请输入费用" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item layui-form-text" style="z-index: 1;">
		<label class="layui-form-label">备注</label>
		<div class="layui-input-block">
			<textarea name="memo" placeholder="请输入备注" class="layui-textarea"></textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-block">
		  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
  </div>
</form>
<script>
	//Demo
	layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('select(auitSelect)',function(data){ //
        	var val = data.value;
        	$('#cardNums').hide();
        	$('#validTime').hide();
        	if(val){
        	    $.ajax({
            		url:"{:U('Common/getGoodsInfo')}",
            		type:'post',
            		dataType:'json',
            		data:cont,
            		success:function(data){
            			if(data.code==1){
            			    $('#cardNums').val(data.data.total_nums);
            			    $('#validTime').val(data.data.valid_time);
            				$('#cardNums').show();
        		            $('#validTime').show();
            			}else{
            			    layer.alert(data.message);
            			}
            		}
            	});
        	}
        });
        form.on('submit(formDemo)', function(data){
        	var cont = data.field;
        	$.ajax({
        		url:"{:U('Users/changeUserCard')}",
        		type:'post',
        		dataType:'json',
        		data:cont,
        		success:function(data){
        			if(data.code==0){
        				layer.alert(data.message);
        			}else{
        				layer.alert(data.message, function(index){
        					//do something
        					window.parent.location.reload();
        					var index = parent.layer.getFrameIndex(window.name); 
        					parent.layer.close(index);
        				});
        			}
        		}
        	});
        	//layer.msg(JSON.stringify(data.field));
        	return false;
        });
	});
</script>
<!-- /. PAGE INNER  -->
<include file="Common:footer" />